// 负责提示信息处理
export default {
	showLodaing(text='处理中...'){
		uni.showLoading({
			title: text,
			mask: false
		});
	},
	hideLodaing(){
		uni.hideLoading();
	},
	// 错误提示弹框
	 showError(msg, duration = 3000) {
		uni.showToast({
			title: msg,
			duration,
			mask: false,
			icon: 'none',
			image: 'https://pic.cwyyt.cn/upload/20210513/1618381838_2021051338656.png'
		})
	},
	/**
	 * 显示提示信息 https://uniapp.dcloud.io/api/ui/prompt.html#showtoast
	 * @param {*} title 
	 * @param {*} icon 
	 * @param {*} duration 
	 */
	showMsg(title,icon='success',duration=2000){
		uni.showToast({
			title: title,
			icon: icon,
			duration: duration
		});
	},
	
	/**
	 * 显示确认弹窗 https://uniapp.dcloud.io/api/ui/prompt.html#showmodal
	 * @example 
	 *  const res= await this.$cw.showConfirm('确认删除?');
		 if(res){} // 做对应事情
	 * @param {*} content 
	 * @param {*} title 
	 * @param {*} showCancel 
	 * @param {*} confirmText 
	 * @param {*} cancelText 
	 */
	async showConfirm(content,title='提示',showCancel=true,confirmText='确定',cancelText='取消'){
		let res= await uni.showModal({
			title: title,
			content: content,
			showCancel: showCancel,
			cancelText: cancelText,
			confirmText:confirmText,
		});
		
		if(res.confirm){
			return res;
		}
	},
	
	/**
	 * 显示输入弹窗 https://uniapp.dcloud.io/api/ui/prompt.html#showmodal
	 * @example 
	 * const res= await this.$cw.showPrompt();
		 if(res.confirm&&!res.content){
			 this.$cw.showMsg('输入不能为空','error');
			 return;
		 }
	 * @param {*} content 
	 * @param {*} title 
	 * @param {*} showCancel 
	 * @param {*} confirmText 
	 * @param {*} cancelText 
	 */
	async showPrompt(content,placeholderText='请输入值',title='提示',showCancel=true,confirmText='确定',cancelText='取消'){
	let [error,res]= await	uni.showModal({
			title: title,
			content: content,
			showCancel: showCancel,
			cancelText: cancelText,
			confirmText:confirmText,
			editable:true,
		});
		return res;
	},
}
